#pragma once
#include "Pascal.h"
#include "hooks.h"
#include "wc3main.h"
#include "wc3jassvm.h"

procedure jassvmhooks_Init();
void jassvmhooks_main();

	typedef procedure (*TInstanceEventCallback)(TInstanceHandle hInstance);
	typedef TScriptExitCode (*TInstanceExecuteFunctionByNameCallback)(TInstanceHandle hInstance, PChar Name, PDword ScriptResult);
	typedef TScriptExitCode (*TInstanceExecuteFunctionByHandleCallback)(TInstanceHandle hInstance, Dword hFunction, PDword ScriptResult);
	typedef TJassStringHandle (*TInstanceGetStringHandleCallback)(TInstanceHandle hInstance, PChar Value);
	typedef procedure (*TEnableVarChangeEventCallback)(PChar VariableName);



	typedef LongBool (__stdcall *TCGameState_ConnectToVarChangeEvent)(PChar variable_name, Dword event_id, PObserver handler); // thiscall

	typedef TInstanceHandle (__stdcall *orig_RegisterInstance_1)();
	typedef procedure (__stdcall *orig_FreeInstance_1)();
	typedef TScriptExitCode (__stdcall *orig_Instance_ExecuteFunctionWithOptionalInit_1)(PChar FunctionName, PDword Result, LongBool InitGlobals, Dword OpLimit, Dword Unused);
	typedef TScriptExitCode (__stdcall *orig_ExecuteFunctionByHandle_1)(Pointer Parameters, PDword ScriptResult, Dword OpLimit, Dword Unused, LongBool ForceNewRun);
	typedef TJassStringHandle (__stdcall *orig_Instance_GetStringHandle_1)(PChar Value);
	typedef TCGameState_ConnectToVarChangeEvent orig_CGameState_ConnectToVarChangeEvent_1;